/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-12-12     MBW       the first version
 */
#include "niming.h"
#include "JY901B_931.h"
#include "data_define.h"
#include "niming_flow.h"
#include "sins.h"
#include "PPM.h"
#include <rtthread.h>
#include <rtdevice.h>
#include "delay_uil.h"
#include "easyblink.h"

ebled_t led1 = RT_NULL;
ebled_t led2 = RT_NULL;


void led_task(void *p)
{
    int count = 0;
    while(1)
    {
        if(control_data.batter_vol<11.8){
                count++;
            if(count>5){
                easyblink(led2, 4, 50, 200);
            }
        }
        else {
            count = 0;
        }
        rt_thread_mdelay(500);
    }
}
void led_task_init(void)
{
    rt_thread_t tid1 = RT_NULL;
    /* 初始化LED1，引脚B口5脚，STM32可以使用GET_PIN()宏，低电平有效 */
    led1 = easyblink_init_led(GET_PIN(C, 0), PIN_LOW);
    /* 初始化LED2，引脚B口3脚，STM32可以使用GET_PIN()宏，低电平有效 */
    led2 = easyblink_init_led(GET_PIN(C, 1), PIN_LOW);
    tid1 = rt_thread_create("led_task",led_task, RT_NULL, 2000,20, 20);
    if (tid1 != RT_NULL)rt_thread_startup(tid1),rt_kprintf("...led_task is ok!\n");
}
INIT_APP_EXPORT(led_task_init);
